package com.woniu.controller.homepage;

import com.woniu.entity.Users;
import com.woniu.service.Impl.homePage.UsersInfoServiceImpl;
import com.woniu.service.Impl.homePage.UsersServiceImpl;
import com.woniu.util.ResData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/app/user")
public class UsersController {
    @Autowired
    UsersServiceImpl usersService;

    @Autowired
    UsersInfoServiceImpl usersInfoService;

    /*发送短信验证码*/
    @RequestMapping("sendCode")
    public ResData<?> sendCode(String phone){
       return usersService.SendCode(phone);
    }

    /*用户通过手机号，验证码 注册*/
    @RequestMapping("/UserRegister")
    public ResData<?> login( String phone, String code){
        return usersService.UsersLoginRegister(phone, code);
    }

    /*分拣端/配送端用户登录方法，传参手机号，密码*/
    @RequestMapping("/otherUsersLogin")
    public ResData<?> otherUsersLogin(@RequestBody Users users){
        return usersService.otherUserLogin(users.getPhone(), users.getPassword());
    }


    /*协作端用户 修改密码 传参，手机号，密码*/
    @RequestMapping("/updatePassword")
    public ResData<?> updatePassword(String phone, String password){
        return usersService.updatePassword(phone, password);
    }

    /*查询用户端和协作端用户数量*/
    @RequestMapping("/usersAndWorkCount")
    public ResData<?> usersAndWorkCount(){
        return usersService.findUsersAndWork();
    }

    /*查询用户的积分和会员等级*/
    @RequestMapping("/queryCreditAndLevel")
    public ResData<?> queryCreditAndLevel(String phone){
        return usersInfoService.queryUserInfoCreditAndLevel(phone);
    }
    /*用户登录*/
    @RequestMapping("/usersLogin")
    public ResData<?> usersLogin(String phone){
        return usersService.UsersLogin(phone);
    }
}
